import { LOGIN, LOGOUT } from '../actionTypes/userActionType';

const INIT_STATE = {
  userId: null,
  username: null,
  authList: [],
  token: null
}

export default function userReducer(state = INIT_STATE, action) {
  switch (action.type) {
    case LOGIN:
      return {
        ...state,
        ...action.payload
      };

    case LOGOUT:
      return {
        userId: null,
        username: null,
        authList: [],
        token: null
      }

    default:
      return state;
  }
}